package com.zx.znav.controller;

import com.zx.znav.constant.Constants;
import com.zx.znav.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 挚爱之夕
 * @version 1.0
 * @implSpec com.zx.znav.controller
 * @since 2023-07-29 9:40
 */
@Controller
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private LinkService linkService;
    @PostMapping
    public String index(Model model, String input){
        model.addAttribute(Constants.LinKS_KEY, linkService.search(input));
        model.addAttribute("input", input);
        return "search";
    }
}
